import {defineStore} from 'pinia'

export const useCommonStore=defineStore('common',{
	//state=>要存放的数据
	state:()=>{
		return{
			recentSearch:[],
			cart:{
				data:{
					1:1
				},
				sum:0
			},
			other:"abc"
		};
	},
	//store.recentSearch=>获取数据=>计算属性
	getters:{
		getRecentSearch():Array{
		return this.recentSearch.slice(-10).reverse()
		}
	},
	//设置,修改数据
	actions:{
		saveRecentSearch(name:string){
			this.recentSearch.push(name)
		}
	},
	  persist:{
		  enabled: true,
		  strategies: [
			  {
				  key:"comm",
				  storage: localStorage
			  }
		  ]
	  }
})